More test for workspaces \w path dependencies
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 14 Jan 2017 22:14:47 +0000 (01:14 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 14 Jan 2017 22:14:47 +0000 (01:14 +0300)
tests/workspaces.rs

index 51cb366c3ed829ca828012505e04b7f4bfdb21f9..6d6be8a2d296e5366b596e0c8a352aa2e84db3b2 100644 (file)
@@ -1128,4 +1128,106 @@ fn path_dep_outside_workspace_is_not_member() {
 
     assert_that(p.cargo("build").cwd(p.root().join("ws")),
                 execs().with_status(0));
-}
\ No newline at end of file
+}
+
+#[test]
+fn test_in_and_out_of_workspace() {
+    let p = project("foo")
+        .file("ws/Cargo.toml", r#"
+            [project]
+            name = "ws"
+            version = "0.1.0"
+            authors = []
+
+            [dependencies]
+            foo = { path = "../foo" }
+
+            [workspace]
+            members = [ "../bar" ]
+        "#)
+        .file("ws/src/lib.rs", r"extern crate foo; pub fn f() { foo::f() }")
+        .file("foo/Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.1.0"
+            authors = []
+
+            [dependencies]
+            bar = { path = "../bar" }
+        "#)
+        .file("foo/src/lib.rs", "extern crate bar; pub fn f() { bar::f() }")
+        .file("bar/Cargo.toml", r#"
+            [project]
+            workspace = "../ws"
+            name = "bar"
+            version = "0.1.0"
+            authors = []
+        "#)
+        .file("bar/src/lib.rs", "pub fn f() { }");
+    p.build();
+
+    assert_that(p.cargo("build").cwd(p.root().join("ws")),
+                execs().with_status(0));
+
+    assert_that(&p.root().join("ws/Cargo.lock"), existing_file());
+    assert_that(&p.root().join("ws/target"), existing_dir());
+    assert_that(&p.root().join("foo/Cargo.lock"), is_not(existing_file()));
+    assert_that(&p.root().join("foo/target"), is_not(existing_dir()));
+    assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
+    assert_that(&p.root().join("bar/target"), is_not(existing_dir()));
+
+    assert_that(p.cargo("build").cwd(p.root().join("foo")),
+                execs().with_status(0));
+    assert_that(&p.root().join("foo/Cargo.lock"), existing_file());
+    assert_that(&p.root().join("foo/target"), existing_dir());
+    assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
+    assert_that(&p.root().join("bar/target"), is_not(existing_dir()));
+}
+
+#[test]
+fn test_path_dependency_under_member() {
+    let p = project("foo")
+        .file("ws/Cargo.toml", r#"
+            [project]
+            name = "ws"
+            version = "0.1.0"
+            authors = []
+
+            [dependencies]
+            foo = { path = "../foo" }
+
+        "#)
+        .file("ws/src/lib.rs", r"extern crate foo; pub fn f() { foo::f() }")
+        .file("foo/Cargo.toml", r#"
+            [project]
+            workspace = "../ws"
+            name = "foo"
+            version = "0.1.0"
+            authors = []
+
+            [dependencies]
+            bar = { path = "./bar" }
+        "#)
+        .file("foo/src/lib.rs", "extern crate bar; pub fn f() { bar::f() }")
+        .file("foo/bar/Cargo.toml", r#"
+            [project]
+            name = "bar"
+            version = "0.1.0"
+            authors = []
+        "#)
+        .file("foo/bar/src/lib.rs", "pub fn f() { }");
+    p.build();
+
+    assert_that(p.cargo("build").cwd(p.root().join("ws")),
+                execs().with_status(0));
+
+    assert_that(&p.root().join("foo/bar/Cargo.lock"), is_not(existing_file()));
+    assert_that(&p.root().join("foo/bar/target"), is_not(existing_dir()));
+
+    assert_that(p.cargo("build").cwd(p.root().join("foo/bar")),
+                execs().with_status(0));
+    // Ideally, `foo/bar` should be a member of the workspace,
+    // because it is hierarchically under the workspace member.
+    assert_that(&p.root().join("foo/bar/Cargo.lock"), existing_file());
+    assert_that(&p.root().join("foo/bar/target"), existing_dir());
+}